<script type="text/javascript">

function restore_action(action_value) {
    if (action_value == '') {
        return false;
    }
    var file_name = $('#file_name').val();
    if (!file_name) {
        show_noticemessage('<?php __e('Please select the data file.'); ?>');
        return false;
    }

    if (action_value == 'download') {
        var download_message = '<a href="' + '<?php echo $html->www('/backup/'); ?>' + file_name + '">请点击右键下载文件</a>';
        show_noticemessage(download_message);
        return false;
    }
    $("input[@type=submit]").attr('disabled','disabled');
    $('#file_name').attr('disabled', 'disabled');
    $.get('<?php echo $html->admin_url('/data_restore/ajax_data_restore/'); ?>' + action_value + '/' + file_name, 
        function(data) {
            show_noticemessage(data);
            if (action_value =='delete' && data == '<?php __e('Delete done.'); ?>') {
                $('option:selected').remove();
            }
            $("input[@type=submit]").attr('disabled','');
            $('#file_name').attr('disabled', '');
        }
    );
    return false;
}
</script>
<div id="content">
<form id="settings" method="post" onsubmit="return restore_action();">
    <table>
      <tbody>
        <tr>
          <th><?php __e('Select a file'); ?></th>
          <td>
        <select id="file_name" size="10" style="width:80%">
        <?php echo $options; ?>
        </select>
    </td>
        </tr>

        <tr class="finalrow">
          <th></th>
          <td>
          <input value="<?php __e('Start restore'); ?>" type="submit" onclick="return restore_action('restore');">&nbsp;
          <input value="<?php __e('Download backup'); ?>" type="submit" onclick="return restore_action('download');">&nbsp;
          <input value="<?php __e('Delete backup'); ?>" type="submit" onclick="return restore_action('delete');">
          </td>
        </tr>
      </tbody>
    </table>
  </form>
</div>
